home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / rlib.zip / RL_CHANG.PRG < prev    next >
Text File  |  1993-01-04  |  2KB  |  56 lines

  1. * Function: CHANGED
  2. * Author..: Richard Low
  3. * Syntax..: CHANGED()
  4. * Notes...: Procedure to test if memory field variables have been updated.
  5. *           This is better than Clipper's UPDATED() function in that once
  6. *           you test for UPDATED() the flag is cleared.  So if you go back
  7. *           into a READ but then do NOT change anything, UPDATED() will be
  8. *           False.  Typically, when testing for UPDATED() you want it to be
  9. *           True if any values have changed since the last replace.
  10. *
  11. *           CHANGED() is to be used in conjunction with MEMORIZE(),
  12. *           SAVEMEMS(), and FORGET() functions.  These functions take
  13. *           all the fields in the current database, and store the field
  14. *           values to memory variables of the same name (prefaced by M->)
  15. *
  16.  
  17. FUNCTION CHANGED
  18.  
  19. PRIVATE f_alias, f_x, f_field, f_memostr
  20.  
  21. *-- get the alias name of the current database
  22. f_alias = ALIAS()
  23.  
  24. *-- go thru all fields in database
  25. FOR f_x = 1 TO FCOUNT()
  26.  
  27.    *-- extract field name for use in macro substitution
  28.    f_field = FIELD(f_x)
  29.  
  30.    *-- first test that a memvar of the field name exists
  31.    IF TYPE('&f_field') = 'U'
  32.       *-- if not, must not have initialized with MEMORIZE(), so default
  33.       RETURN (UPDATED())
  34.    ENDIF
  35.  
  36.    *-- if field type is a memo field
  37.    IF TYPE('&f_field') = 'M'
  38.       *-- must store the memo field to a string for comparison,
  39.       *-- since memo fields cannot be directly compared to strings
  40.       *-- otherwise we get a TYPE MISMATCH error.
  41.       f_memostr = &f_alias.->&f_field
  42.       IF .NOT. M->&f_field == f_memostr
  43.          RETURN (.T.)
  44.       ENDIF
  45.    ELSE
  46.  
  47.       *-- otherwise see if field contents match memory variables edited
  48.       IF .NOT. M->&f_field == &f_alias.->&f_field
  49.          RETURN (.T.)
  50.       ENDIF
  51.    ENDIF
  52.  
  53. NEXT f_x
  54.  
  55. RETURN (.F.)
  56.